
************************MECH DATA********************************
********Table 2: Balance on Baseline Characteristics*********
use if (t==-1 & (taxyr_cut==1980 | taxyr_cut==1985 | taxyr_cut==1990)) | (t==-2 & (taxyr_cut==1981 | taxyr_cut==1986 | taxyr_cut==1991)) ///
  		using ${clean_data}/taxtax_parents_mech1_clean, clear

regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\}  @{r_/restrict\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
				 runs{ outcome[ male white_non_hisp black hisp tyrc_maxage parent_i_1040 i_married0 tyrc_pragiz parent_wagez i_pov0 ] ///
				 sample[ k1elig ] ///
				 predsamp[ predL12 ] ///
				 t[neg12] ///
				 taxyrcuts[ 1979_1991 ] ///
				 restrict[ all ]  ///
				 covars[ tyrc ] ///
				 sch_cuts[dropany_miss ] ///
				 donut[ 8  ] ///
				 wdays[ 20 ] } ///
				 coeffs{bcut[1.belowcut]} ///
				 stats{mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0] } ///
				 dataout{${results}/final_t2} fileout{${results}/final} sheetout{t2} $option


**Cash Transfer in Infancy by group/years for second to last row of various tables**
global groups_1979_1991 = "all male female Lsingle Lmarried Lfilers Lnofilers black black_male hisp hisp_male white_non_hisp white_non_hisp_male"
global groups_1980_1981 = "all "
global groups_1985_1986 = "all "
global groups_1990_1991 = "all black hisp white_non_hisp"
foreach tyrc in 1979_1991 1980_81 1985_1986 1990_1991 {
  foreach samp of global groups_`tyrc' {
    disp "********** `samp' -- `tyrc' *********"
    summ tyrc_prdtax_taxsimL0 if @{tyrcs_/taxyrcuts\} &inrange(z,-20-8,20+8-1)& !inrange(z,-8,8-1)  ${r_k1elig}  @{r_`samp'} ${a_23} ${sc_dropany_miss} ${rp_predL12} & belowcut==1
  }
}

************************KID DATA********************************
use ${clean_data}/taxtax_clean if taxyr_cut<=1991 ${rp_ob0_predL12} ${sc_dropany_miss} & inrange(agecyr,23,30), clear
*rename taxyr_out year
rename  tyrc_obstyr i_obstaxyr
rename pob_fips pob

********Table 3: Effect of Eligibility on Adult Earnings*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
				runs{ outcome[ wagez3 ] ///
				sample[ k1elig ] ///
				predsamp[ predL12 ] ///
				ages[ 23 26 ] ///
				taxyrcuts[1979_1991 ] ///
				restrict[ all ]  ///
				covars[ tyrc taxdem taxincLf0 ] ///
				sch_cuts[dropany_miss ] ///
				donut[ 8  ] ///
				wdays[ 20 ] } ///
				coeffs{bcut[1.belowcut]} ///
				stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] } ///
				dataout{${results}/final_t3} fileout{${results}/final} sheetout{t3} $option

********Table 4: Effect of Eligibility on Adult Earnings By Cohort*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
				runs{ outcome[ wagez3 ] ///
				sample[ k1elig ] ///
				predsamp[ predL12 ] ///
				ages[ 23 26 ] ///
				taxyrcuts[1980_1981 1985_1986 1990_1991 1979_1991 ] ///
				restrict[ all ]  ///
				covars[ tyrc ] ///
				sch_cuts[dropany_miss ] ///
				donut[ 8  ] ///
				wdays[ 20 ] } ///
				coeffs{bcut[1.belowcut]} ///
				stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] } ///
				dataout{${results}/final_t4} fileout{${results}/final} sheetout{t4} $option

********Table 5: Heterogeneity in the Eect of Eligibility on Adult Earnings*********
 regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
          runs{ outcome[ wagez3 ] ///
          sample[ k1elig ] ///
          predsamp[ predL12 ] ///
          ages[ 23 26 ] ///
          taxyrcuts[  1979_1991 ] ///
          restrict[ all male female Lsingle Lmarried Lfilers Lnofilers   ]  ///
          covars[ tyrc ] ///
          sch_cuts[dropany_miss ] ///
          donut[ 8  ] ///
          wdays[ 20 ] } ///
          coeffs{bcut[1.belowcut]} ///
          stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] } ///
          dataout{${results}/final_t5} fileout{${results}/final} sheetout{t5} $option

********Table 6: Heterogeneity by Race/Ethnicity in the Effect of Eligibility on Adult Earnings*********
global groups_1979_1991 = "black black_male hisp hisp_male white_non_hisp white_non_hisp_male"
global groups_1990_1991 = "black hisp white_non_hisp"
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
          runs{ outcome[ wagez3 ] ///
          sample[ k1elig ] ///
          predsamp[ predL12 ] ///
          ages[ 23 26 ] ///
          taxyrcuts[  1979_1991 1990_1991] ///
          restrict[ @{groups_/taxyrcuts\}  ]  ///
          covars[ tyrc ] ///
          sch_cuts[dropany_miss ] ///
          donut[ 8  ] ///
          wdays[ 20 ] } ///
          coeffs{bcut[1.belowcut]} ///
          stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] } ///
          dataout{${results}/final_t6} fileout{${results}/final} sheetout{t6} $option


***********************************************************************
*APPENDIX TABLES
***********************************************************************

********Table A5: Effect of Eligibility on Adult Earnings Percentile*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
				runs{ outcome[ pwagez3 ] ///
				sample[ k1elig ] ///
				predsamp[ predL12 ] ///
				ages[ 23 26 ] ///
				taxyrcuts[1979_1991 ] ///
				restrict[ all ]  ///
				covars[ tyrc taxdem taxincLf0 ] ///
				sch_cuts[dropany_miss ] ///
				donut[ 8  ] ///
				wdays[ 20 ] } ///
				coeffs{bcut[1.belowcut]} ///
				stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] } ///
				dataout{${results}/final_ta5} fileout{${results}/final} sheetout{ta5} $option


********Table A6: Effect of Eligibility on Adult Earnings of Non-First-Born By Cohort*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
				runs{ outcome[ wagez3 ] ///
				sample[ k2elig ] ///
				predsamp[ predL12 ] ///
				ages[ 23 26 ] ///
				taxyrcuts[1980_1981 1985_1986 1990_1991 1979_1991 ] ///
				restrict[ all ]  ///
				covars[ tyrc taxdem taxincLf0 ] ///
				sch_cuts[dropany_miss ] ///
				donut[ 8  ] ///
				wdays[ 20 ] } ///
				coeffs{bcut[1.belowcut]} ///
				stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] } ///
				dataout{${results}/final_ta6} fileout{${results}/final} sheetout{ta6} $option

********Table A7: Effect of Eligibility on Marital Status*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
				runs{ outcome[ i_married0 ] ///
 				sample[ k1elig ] ///
 				predsamp[ predL12 ] ///
 				ages[ 23 26 ] ///
 				taxyrcuts[  1979_1991 ] ///
 				restrict[all male female ]  ///
 				covars[ tyrc ] ///
 				sch_cuts[dropany_miss ] ///
 				donut[ 8  ] ///
 				wdays[ 20 ] } ///
 				coeffs{bcut[1.belowcut]} ///
 				stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] ///
 					 } ///
 				dataout{${results}/final_ta7} fileout{${results}/draft} sheetout{ta7} $option

********Table A8: Effect of Eligibility on Adult Earnings of Non-First-Born By Cohort*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\} @{r_/restrict\} @{a_/ages\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
			  runs{ outcome[ wagez3 ] ///
				sample[ k1elig ] ///
				predsamp[ predL12 ] ///
				ages[ 23 26 ] ///
				taxyrcuts[ 1980_1981 1985_1986 1990_1991 1979_1991 ] ///
				restrict[ male female ]  ///
				covars[ tyrc ] ///
				sch_cuts[dropany_miss ] ///
				donut[ 8  ] ///
				wdays[ 20 ] } ///
				coeffs{bcut[1.belowcut]} ///
				stats{ mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ] ///
					 } ///
				dataout{${results}/final_ta8} fileout{${results}/draft} sheetout{ta8} $option


************************KID DATA w/ county of birth chars********************************
use ${clean_data}/taxtax_pobchars, clear

********Table A1: Effect of Eligibility on Adult Earnings of Non-First-Born By Cohort*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\}  @{r_/restrict\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})" , ///
				 runs{ outcome[ kpobc80_pop kpobc80med_faminc kpobc80p_pov100 kpobc80p_bl kpobc80p_wh kpobc80p_hisp kpobc80p_a5 kpobc80p_a65 kpobc80p_hsdrop kpobc80p_baplus kpobc80r_lfp ] ///
				 sample[ k1elig ] ///
				 predsamp[ predL12 ] ///
				 taxyrcuts[ 1979_1991 ] ///
				 restrict[ all ]  ///
				 covars[ tyrc ] ///
				 sch_cuts[dropany_miss] ///
				 donut[ 8  ] ///
				 wdays[ 20 ] } ///
				 coeffs{bcut[1.belowcut]} ///
				 stats{	mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ]  } ///
				 dataout{${results}/final_ta1} fileout{${results}/draft} sheetout{ta1} $option


************************Cumulative Parent Data********************************
use if inrange(t,3,3) using ${clean_data}/taxtax_parents_mech1_clean, clear
tempfile orig_vars
save `orig_vars'


use if inrange(t,-2,19) using ${clean_data}/taxtax_parents_mech1_clean, clear
xtset pik t
tsfill, full
egen pikmaxwagez = max(parent_wagez), by(pik)
by pik: ipolate parent_wagez t, gen(parent_wagezi) epolate
replace parent_wagezi = pikmaxwagez if parent_wagezi> pikmaxwagez & parent_wagezi!=.
replace parent_wagezi = 0 if parent_wagezi<0 & parent_wagezi!=.

keep if inrange(t,0,18)
gen parent_wagezid = parent_wagezi/((1+.03)^t)

gen parent_bg_ppov13_18 = bg_ppov if inrange(t,13,18)
gen parent_bg_ppov7_12 = bg_ppov if inrange(t,7,12)
gen parent_bg_ppov0_6 = bg_ppov if inrange(t,0,6)

rename i_married parent_i_married
rename  i_married0 parent_i_married0

collapse (sum) cum_wagezid=parent_wagezid cum_wagezi=parent_wagezi (mean) mean_wagezi=parent_wagez mean_wagez=parent_wagez  mean_1040=parent_i_1040 mean_pov0=i_pov0 mean_bg_ppov0_6=parent_bg_ppov0_6 mean_bg_ppov7_12=parent_bg_ppov7_12 mean_bg_ppov13_18=parent_bg_ppov13_18 (max) max_nkids=child_tot max_1040=parent_i_1040 max_married=parent_i_married max_married0=parent_i_married0 max_pov=i_pov max_pov0=i_pov0 max_intinv0=i_intinv0  (min) min_pov0=i_pov0 min_1040=parent_i_1040 min_married=parent_i_married min_married0=parent_i_married0 , by(pik)

/*get time-invariant variables*/
merge 1:1 pik using `orig_vars', keep(match)


gen ever_married0 = max_married0
gen ever_single0 = (min_married0==0) if min_married0!=.

********Table A9: Effect of Cash Transfer Eligibility on Parent Outcomes*********
regrunner "reghdfe /outcome\ i.belowcut##c.z @{x_/covars\} if  @{tyrcs_/taxyrcuts\} &inrange(z,-/wdays\-/donut\,/wdays\+/donut\-1)& !inrange(z,-/donut\,/donut\-1)  @{r_/sample\}  @{r_/restrict\} @{sc_/sch_cuts\} @{rp_/predsamp\}, absorb(@{fe_/covars\}) vce(@{sehdfe_clust_z})", ///
					 runs{ outcome[ cum_wagezid mean_wagez min_1040 mean_pov0 min_pov0 ever_single0 ever_married0  ] ///
					 sample[ k1elig ] ///
					 predsamp[ predL12 ] ///
					 t[ 0_18 ] ///
					 taxyrcuts[ 1979_1991 ] ///
					 restrict[ all Lfilers ]  ///
					 covars[ tyrc ] ///
					 sch_cuts[dropany_miss ] ///
					 donut[ 8  ] ///
					 wdays[ 20 ] } ///
					 coeffs{bcut[1.belowcut]} ///
					 stats{	mean0[r(mean), summ /outcome\ if e(sample) & belowcut==0 ]  } ///
					 dataout{${results}/final_ta9} fileout{${results}/draft} sheetout{ta9} $option



************************Full Year Data********************************
use ${clean_data}/taxtax_fullyr_clean if age==23 & (inrange(taxyr_cut,1980,1981) | inrange(taxyr_cut,1985,1986) | inrange(taxyr_cut,1990,1991)), replace

global outcomes = "tyrc_Lmarried0 tyrc_teenmom_exact white_non_hisp"
global x_ts = "t tsqr tcub"

gen qtr = 1 if dob_month!=.
replace qtr = 2 if inrange(dob_month,4,6)
replace qtr = 3 if inrange(dob_month,7,9)
replace qtr = 4 if inrange(dob_month,10,12)

********Table A2: Comparison of Average Family Characteristics in December versus January*********
regrunner "reg /outcome\ i.dob_month @{x_/covars\} if @{tyrcs_/taxyrcuts\} @{r_/sample\}  @{r_/restrict\} @{sc_/sch_cuts\} @{rp_/predsamp\}, robust" , ///
      runs{ outcome[ ${outcomes}  ] ///
      sample[ all k1elig ] ///
      predsamp[ predL12 ] ///
      taxyrcuts[ 1979_1991 ] ///
      restrict[ all ]  ///
      covars[ ts ] ///
      sch_cuts[dropany_miss]  } ///
      coeffs{ m12[12.dob_month] } ///
      stats{ftest[r(p), testparm i(2/12).dob_month ] ///
        	  mean[r(mean), summ /outcome\ if e(sample) ]  } ///
      dataout{${results}/final_ta2} fileout{${results}/final} sheetout{ta2} $option
